import config from '@/nxTemp/config/index.config.js';
export function  uploadFile(url,filePath,formData){
	let header = {}
	header['token'] = uni.getStorageSync('token')

	return new Promise((resolve, reject) => {

		uni.uploadFile({
			url: config.baseUrl + url,

			filePath: filePath,
			//	files: data.data,
			name: 'file',
			formData: formData,
			header: header,
			success: response => {
				var res = JSON.parse(response.data)

				if (res.code == 0) {
					resolve(res)
				} else {
					uni.showToast({
						title: res.msg,
						icon: "none"
					});

					reject(res.msg)
				}
			},
			fail: error => {
				uni.showToast({
					title: error.errMsg,
					icon: "none"
				});
				reject(error.errMsg)
			}
		})
	})
}
